//
//  FRMeViewController.m
//  Live
//
//  Created by 徐芙蓉 on 2017/9/5.
//  Copyright © 2017年 Afra. All rights reserved.
//

#import "FRMeViewController.h"
#import "FRMeInfoView.h"
#import "FRSetting.h"

@interface FRMeViewController ()

@property(nonatomic, strong) NSArray *datalist;

@property(nonatomic, strong) FRMeInfoView *infoView;

@end

@implementation FRMeViewController

-(FRMeInfoView *)infoView
{
    if (!_infoView) {
        _infoView = [FRMeInfoView loadInfoView];
        _infoView.frame = CGRectMake(0, 0, 0, SCREEN_HEIGHT * 0.4);
    }
    return _infoView;
}

-(void)viewWillAppear:(BOOL)animated
{
    [super viewWillAppear:animated];
    self.automaticallyAdjustsScrollViewInsets = NO;
    self.navigationController.navigationBarHidden = YES;
}

-(void)viewWillDisappear:(BOOL)animated
{
    [super viewWillDisappear:animated];
    self.navigationController.navigationBarHidden = NO;
}

- (void)viewDidLoad {
    [super viewDidLoad];
    self.tableView.tableHeaderView = self.infoView;
    self.tableView.rowHeight = 60;
    self.tableView.sectionFooterHeight = 0;
    
    [self loadData];
}

-(void)loadData
{
    FRSetting *set1 = [[FRSetting alloc] init];
    set1.title = @"映客贡献榜";
    set1.subTitle = @"";
    set1.vcName = @"FRGongViewController";
    
    FRSetting *set2 = [[FRSetting alloc] init];
    set2.title = @"收益";
    set2.subTitle = @"0 映票";
    set2.vcName = @"FRShouViewController";
    
    FRSetting *set3 = [[FRSetting alloc] init];
    set3.title = @"账户";
    set3.subTitle = @"0 钻石";
    set3.vcName = @"FRZhangViewController";
    
    FRSetting *set4 = [[FRSetting alloc] init];
    set4.title = @"等级";
    set4.subTitle = @"3 级";
    set4.vcName = @"FRDengViewController";
    
    FRSetting *set5 = [[FRSetting alloc] init];
    set5.title = @"设置";
    set5.subTitle = @"";
    set5.vcName = @"FRSettingViewController";
    
    NSArray *arr1 = @[set1,set2,set3];
    NSArray *arr2 = @[set4];
    NSArray *arr3 = @[set5];
    
    self.datalist = @[arr1,arr2,arr3];
}

- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

#pragma mark - Table view data source

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView {

    return self.datalist.count;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section {

    NSArray *arr = self.datalist[section];
    return arr.count;
}


- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath {
    UITableViewCell *cell = [[UITableViewCell alloc] initWithStyle:UITableViewCellStyleValue1 reuseIdentifier:nil];
   
    FRSetting *set = self.datalist[indexPath.section][indexPath.row];
    
    cell.textLabel.text = set.title;
    cell.detailTextLabel.text = set.subTitle;
    cell.accessoryType = UITableViewCellAccessoryDisclosureIndicator;
    
    return cell;
}

-(CGFloat)tableView:(UITableView *)tableView heightForHeaderInSection:(NSInteger)section
{
    if (section == 0) {
        return 0;
    }
    return 5;
}


@end
